;-----------------------------------------------------------------

; When drawing the Scouter, there are three sprites for the main body.  One sprite is
; used for when the Scouter is standing still.  The other two are used for movement,
; switching the two sprites back and forth.  These sprites require a mask.

; There are only 16 turret sprites, as opposed to the usual 32.  These sprites are OR-ed
; to the screen.

;---------------------------------------------------------------------------------------

;Variables used:
;Player1_X
;Player1_Y
;Player1_Turret_Position, where 0 is equal to pointing West
;Sprite_Width, This allows sprites to be more than eight pixels wide
Draw_Scouter:

 LD A, 2
 LD (Sprite_Width),A
 LD A, E
 LD B, A
 ADD A,A
 ADD A,A
 ADD A,A
 ADD A,A
 ADD A, B
 ADD A, B
 ADD A, B
 ADD A, B
 LD C, A
 LD B, 0
 LD IX, Scouter_Moving
 ADD IX, BC
 LD B, 5
  LD A, (Player1_Y)
 ADD A, 16
 LD L, A
  LD A,(Player1_X)


 CALL Put_Sprite_Mask
 



 LD A, (Player1_Y)
 LD L, A
 LD A, (Player1_X)
 LD IX, Scouter_Standing_Still
 LD B, 16

 CALL Put_Sprite_Mask


 
 LD A, 1
 LD (Sprite_Width), A

 LD A, (Player1_Turret_Position)
 LD B, A
 ADD A, A ;Multiply A by 7, since each turret has 7 bytes of data
 ADD A, A
 ADD A, A
 SUB B
 LD IX, Scouter_Turrets
 LD B,0
 LD C, A
 ADD IX, BC
 LD E, (IX)
 
  ;IX now points to the offset of the arms, so store that in a
  ;register to add later to the sprite X position
 INC IX ;IX now points to the turret

 LD B, 6
 
 
 LD A, (Player1_Y)
 ADD A, 10
 
 LD L, A

 LD A, (Player1_X)
 ADD A, E
 SUB 1
 CALL Put_Sprite_OR
 

 
 
 
 RET












Scouter_Standing_Still:





    .db %00001110,%00000000,%00000000,%00000000
    .db %00110001,%00001110,%10000000,%00000000
    .db %01000000,%00111111,%01000000,%10000000
    .db %01000000,%00111111,%11000000,%00000000
    .db %10000001,%01111110,%01100000,%10000000
    .db %10000010,%01111101,%11100000,%00000000
    .db %10000101,%01111010,%11100000,%00000000
    .db %01001011,%00110100,%11000000,%00000000
    .db %01110111,%00001000,%11000000,%00000000
    .db %00111111,%00000000,%10000000,%00000000
    .db %00001110,%00000000,%00000000,%00000000
    .db %00001010,%00000100,%00000000,%00000000
    .db %00001010,%00000100,%00000000,%00000000
    .db %00001010,%00000100,%00000000,%00000000
    .db %00001110,%00000000,%00000000,%00000000
    .db %00001010,%00000100,%00000000,%00000000






Scouter_Moving:

 ;If A = 0   
    .db %11111011,%00000100,%11000000,%00000000
    .db %00011111,%00000000,%00100000,%00000000
    .db %01100100,%00000000,%10000000,%00000000
    .db %01000100,%00000000,%01000000,%00000000
    .db %00000000,%00000000,%01000000,%00000000

  ;If A = 1
    .db %01111011,%00000100,%11100000,%00000000
    .db %10011111,%00000000,%00000000,%00000000
    .db %00100100,%00000000,%11000000,%00000000
    .db %01000100,%00000000,%01000000,%00000000
    .db %01000100,%00000000,%00000000,%00000000

 ;If A = 2, meaning the Scouter is standing still
    .db %01111011,%00000100,%11000000,%00000000
    .db %10011111,%00000000,%00100000,%00000000
    .db %00100100,%00000000,%10000000,%00000000
    .db %01000100,%00000000,%01000000,%00000000
    .db %01000100,%00000000,%01000000,%00000000



; The first byte is the offset of the spriteb, the x position for drawing the
; sprite (stored in register A) is added by this value.

Scouter_Turrets:

 ; First position, pointing West
 .db 0
 .db  00000111b
 .db  00000101b
 .db  01111101b
 .db  00000101b
 .db  00111111b
 .db  00000101b


 .db 0
 .db  00000111b
 .db  00001101b
 .db  00100101b
 .db  00010101b
 .db  00001101b
 .db  00000101b


 ; Pointing North
 .db 1
 .db  00001110b
 .db  00011011b
 .db  00011011b
 .db  00011011b
 .db  00001010b
 .db  00001010b

 .db 3
 .db  00111000b
 .db  00101101b
 .db  00101010b
 .db  00101100b
 .db  00101000b
 .db  00101000b


 ;Pointing East
 .db 4
 .db  01110000b
 .db  01010000b
 .db  01011111b
 .db  01010000b
 .db  01111110b
 .db  01010000b

 .db 2
 .db  00011100b
 .db  00010100b
 .db  00010110b
 .db  00011101b
 .db  00010110b
 .db  00010100b


 ;Pointing South
 .db 1
 .db  00001110b
 .db  00001010b
 .db  00011011b
 .db  00011011b
 .db  00011011b
 .db  00001010b


 .db 0
 .db  00000111b
 .db  00000101b
 .db  00001101b
 .db  00010111b
 .db  00001101b
 .db  00000101b

